package com.sky.distribution.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sky.common.annotation.Log;
import com.sky.common.core.controller.BaseController;
import com.sky.common.core.domain.AjaxResult;
import com.sky.common.enums.BusinessType;
import com.sky.distribution.domain.TbFilmDistribution;
import com.sky.distribution.service.ITbFilmDistributionService;
import com.sky.common.utils.poi.ExcelUtil;
import com.sky.common.core.page.TableDataInfo;

/**
 * 影片发行管理Controller
 * 
 * @author ruoyi
 * @date 2025-11-08
 */
@RestController
@RequestMapping("/distribution/distribution")
public class TbFilmDistributionController extends BaseController
{
    @Autowired
    private ITbFilmDistributionService tbFilmDistributionService;

    /**
     * 查询影片发行管理列表
     */
    @PreAuthorize("@ss.hasPermi('distribution:distribution:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbFilmDistribution tbFilmDistribution)
    {
        startPage();
        List<TbFilmDistribution> list = tbFilmDistributionService.selectTbFilmDistributionList(tbFilmDistribution);
        return getDataTable(list);
    }

    /**
     * 导出影片发行管理列表
     */
    @PreAuthorize("@ss.hasPermi('distribution:distribution:export')")
    @Log(title = "影片发行管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbFilmDistribution tbFilmDistribution)
    {
        List<TbFilmDistribution> list = tbFilmDistributionService.selectTbFilmDistributionList(tbFilmDistribution);
        ExcelUtil<TbFilmDistribution> util = new ExcelUtil<TbFilmDistribution>(TbFilmDistribution.class);
        util.exportExcel(response, list, "影片发行管理数据");
    }

    /**
     * 获取影片发行管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('distribution:distribution:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbFilmDistributionService.selectTbFilmDistributionById(id));
    }

    /**
     * 新增影片发行管理
     */
    @PreAuthorize("@ss.hasPermi('distribution:distribution:add')")
    @Log(title = "影片发行管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbFilmDistribution tbFilmDistribution)
    {
        return toAjax(tbFilmDistributionService.insertTbFilmDistribution(tbFilmDistribution));
    }

    /**
     * 修改影片发行管理
     */
    @PreAuthorize("@ss.hasPermi('distribution:distribution:edit')")
    @Log(title = "影片发行管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbFilmDistribution tbFilmDistribution)
    {
        return toAjax(tbFilmDistributionService.updateTbFilmDistribution(tbFilmDistribution));
    }

    /**
     * 删除影片发行管理
     */
    @PreAuthorize("@ss.hasPermi('distribution:distribution:remove')")
    @Log(title = "影片发行管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbFilmDistributionService.deleteTbFilmDistributionByIds(ids));
    }
}
